<?php $this->pageTitle = 'Thông tin thành viên ' . $codeActive->courses->name . ' [ ' . $member->fullname. ' ]' ;?>
<div id ="achor-profile-reload"></div>
<div class="content" style="text-align: left">
	<div class="account-profile">
		<table cellpadding="0" cellspacing="0" width="100%">
			<tbody>
				<tr valign="top">
					<td width="75%" class="left-column">
						<div id="businessCardView" class="sliding-panel business-card showing-panel">
							<div class="avatar-area">
								<div class="border-grprofile" id="avatar-show">
									<?php echo CHtml::image(Util::getImageExist("profile", $member->avatar), "avatar",  array("class" =>"grprofile", 'id' => 'avatar-now'));?>
								</div>
								<div class="change-avatar">
									<span id="setfielupload">Đổi hình ảnh</span>
									<br/><span id="cancelfielupload">Hủy bỏ</span>
									<?php echo CHtml::fileField('avatar','',array('id'=> 'fileupload')); ?>
								</div>
								<div class="change-info-profile">
									<?php echo CHtml::button('Cập nhật thông tin', array('class' => 'btn btn-default', 'id' => 'update-profile')); ?>
									<br/><br/>
									<?php echo CHtml::button('Thay đổi mật khẩu', array('class' => 'btn btn-default', 'id' => 'update-password')); ?>
								</div>
							</div>
							<div id="user-profile-view">
								<?php $this->widget('ProfileView', array('member' => $member, 'type' => 'profile'))?>
							</div>
						</div>
					</td>
					<td align="right" class="right-column" style="vertical-align: top">
						<table>
							<tr>
								<td><?php echo CHtml::encode($account->getAttributeLabel('username'));?></td>
								<td class="ta-left">
									<div class="legendColorBox"  style="width: 54px;">
										<div class="legendColor" style="background: #8ec657; width: 50px; text-align: center;">
											<?php echo CHtml::encode($account->username);?></div>
									</div>
								</td>
							</tr>
							<tr>
								<td><?php echo $account->getAttributeLabel('status');?></td>
								<td class="ta-left"><?php echo Util::itemAlias('UserStatus', $account->status);?></td>
							</tr>
							<tr>
								<td><?php echo $account->getAttributeLabel('create_at');?></td>
								<td class="ta-left"><?php echo Util::formatTime($account->create_at, true, '-');?></td>
							</tr>
							<tr>
								<td><?php echo $account->getAttributeLabel('lastvisit_at');?></td>
								<td class="ta-left"><?php echo Util::formatTime($account->lastvisit_at, true, '-', true);?></td>
							</tr>
						</table>
					</td>
				</tr>
			</tbody>
		</table>
		<div id="user-social-view">
			<?php $this->widget('ProfileView', array('member' => $member, 'type' => 'social'));?>
		</div>
	</div>
	<div class="clear"></div>
	<div class="account-profile">
		<h1 class="header-scholarship">Thông tin ân nhân</h1>
		<table class="education-info">
			<tr>
				<td align="right"><strong><?php echo CHtml::encode($member->getAttributeLabel('donor_name'));?></strong></td>
				<td class=""><?php echo CHtml::encode($member->donor_name);?></td>
			</tr>
			<tr>
				<td align="right"><strong><?php echo CHtml::encode($member->getAttributeLabel('donor_email'));?></strong></td>
				<td class=""><?php echo CHtml::encode($member->donor_email)?></td>
			</tr>
			<tr>
				<td align="right"><strong><?php echo CHtml::encode($member->getAttributeLabel('donor_address'));?></strong></td>
				<td class=""><?php echo CHtml::encode($member->donor_address)?></td>
			</tr>
		</table>
	</div>
	<div class="clear"></div>
	<div class="account-profile">
		<h1 class="header-scholarship">Bảng tóm tắt hoạt động tại CLB</h1>
		<table cellpadding="0" cellspacing="0" width="100%">
			<tbody>
				<tr valign="top">
					<td width="300px;" class="left-column" style="vertical-align: top">
				        <div class="clear"></div>
						<table class="table-bordered">
				          <tbody>
				            <tr>
				              <td>Số lần gửi thư thăm hỏi ân nhân</td>
				              <td width="20px;" class="td-number">
									<strong><?php echo CHtml::linkButton($donorVisit, array('class' => 'a1', 'id' => 'update-donorVisit')); ?></strong>
				              </td>
				            </tr>
				            <tr>
				              <td>Số lần được mời sinh hoạt</td>
				               <td class="td-number">
									<strong id="statistic-asigned"><?php echo $statistic['asigned'];?></strong>
				              </td>
				            </tr>
				            <tr>
				              <td>Số lần tham gia</td>
				             <td class="td-number">
									<strong  id="statistic-joined"><?php echo $statistic['joined'];?></strong>
				              </td>
				            </tr>
				            <tr>
				              <td>Số lần không tham gia</td>
				              <td class="td-number">
									<strong  id="statistic-absence"><?php echo $statistic['absence'];?></strong>
				              </td>
				            </tr>
				          </tbody>
				        </table>
				        <br/>
					</td>
					<td class="right-column fieldset-none" style="vertical-align: top">
						<div class = "div-fieldset fieldtype-icon1">
						<?php $this->beginWidget('ext.coolfieldset.JCollapsibleFieldset', array(
					        'legend'=>'Chi tiết các buổi tham dự'
					    )); ?>
					    	<?php if (isset($announcements)) :?>
							<ul id = 'announcements-list'>
								<?php foreach($announcements as $announcement) : ?>
								<li><span><?php echo CHtml::link(CHtml::encode($announcement->title), array('/site/view', 'id' => $announcement->id), array('target' => '_blank'))?></span></li>
								<?php endforeach;?>
							</ul>
							<?php endif; ?>
						<?php $this->endWidget(); ?>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
		 <br/>
	</div>
	<div class="clear"></div>
	<div class="account-profile">
		<h1 class="header-scholarship">Bảng thành tích học tập</h1>
		<?php if (isset($edutionActive)) :?>
		<table cellpadding="0" cellspacing="0" width="100%">
			<tbody>
				<tr valign="top">
					<td width="50px;" class="left-column" style="vertical-align: top">
						<div class="legendBox">
							<table cellspacing="2" cellpadding="3">
								<tbody>
								<tr class="legendSelect" id="<?php echo $edutionActive->id?>">
									<td>
										<?php echo CHtml::button('Cập nhật', array('class' => 'btn btn-default', 'id' => 'update-education')); ?>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					</td>

					<td class="right-column fieldset-none" style="vertical-align: top" id="user-semester-view">
						<?php $this->widget('SemesterView', array('education' => $edutionActive, 'current' => true)); ?>
					</td>
				</tr>
			</tbody>
		</table>
		<?php endif;?>
	</div>
</div>
<script type="text/javascript">
    var url =  '<?php echo Yii::app()->createUrl('account/changeAvatar')?>';
    $(document).ready(function() {
    	$("#update-education").click(function() {
            $.fancybox.open({
            	autoDimensions: true,
                href : '<?php echo $this->createUrl('education', array('ajax' => true)) ?>',
                type : 'iframe',
                beforeClose: function(){
	           	 $.ajax({
	                    type: "POST",
	                    url: '<?php echo $this->createUrl('reloadEducation') ?>',
	                    //data: params,
	                    success: function(data) {
	                       $('#user-semester-view').html(data);
	                    } //success
	                });//ajax
	           },
                afterClose: function(){
//	        	   window.location = window.location.pathname;
                }
            });
            return false;
        });

    	$("#update-donorVisit").click(function() {
            $.fancybox.open({
            	autoDimensions: true,
                href : '<?php echo $this->createUrl('donorVisit', array('ajax' => true)) ?>',
                type : 'iframe',
                beforeClose: function(){
	           	 $.ajax({
	                    type: "POST",
	                    url: '<?php echo $this->createUrl('reloadDonorVisit') ?>',
	                    //data: params,
	                    success: function(data) {
	                       $('#update-donorVisit').text("" + data + "");
	                    } //success
	                });//ajax
	           },
                afterClose: function(){
//	        	   window.location = window.location.pathname;
                }
            });
            return false;
        });

    	$("#update-profile").click(function() {
            $.fancybox.open({
                href : '<?php echo $this->createUrl('profile', array('ajax' => true)) ?>',
                type : 'iframe',
                beforeClose: function(){
	           	 $.ajax({
	           			dataType: 'json',
	                    type: "POST",
	                    url: '<?php echo $this->createUrl('reloadProfile') ?>',
	                    //data: params,
	                    success: function(data) {
	                       $('#user-profile-view').html(data['info']);
	                       $('#user-social-view').html(data['social']);

	                       offset = $("#achor-profile-reload").offset();
                			$("html,body").animate({
                			    scrollTop: offset.top,
                			    scrollLeft: offset.left
                			});
	                    }
	                });
	           },
                afterClose: function(){
//	        	   window.location = window.location.pathname;
                }
            });
            return false;
        });
    	$("#update-password").click(function() {
            $.fancybox.open({
                href : '<?php echo $this->createUrl('changepassword', array('ajax' => true)) ?>',
                type : 'iframe',
                afterClose: function(){
//	        	   window.location = window.location.pathname;
                }
            });
            return false;
        });
	});
</script>
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<?php Util::registerScriptFile(Util::themeUrl().'/js/uploadImage/jquery.ui.widget.js');?>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<?php Util::registerScriptFile(Util::themeUrl().'/js/uploadImage/load-image.min.js');?>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<?php Util::registerScriptFile(Util::themeUrl().'/js/uploadImage/jquery.iframe-transport.js');?>
<!-- The basic File Upload plugin -->
<?php Util::registerScriptFile(Util::themeUrl().'/js/uploadImage/jquery.fileupload.js');?>
<!-- The File Upload processing plugin -->
<?php Util::registerScriptFile(Util::themeUrl().'/js/uploadImage/jquery.fileupload-process.js');?>
<!-- The File Upload image preview & resize plugin -->
<?php Util::registerScriptFile(Util::themeUrl().'/js/uploadImage/jquery.fileupload-image.js');?>
<!-- The File Upload validation plugin -->
<?php Util::registerScriptFile(Util::themeUrl().'/js/uploadImage/jquery.fileupload-validate.js');?>
<!-- The control js upload image -->
<?php Util::registerScriptFile(Util::themeUrl().'/js/change-image.js');?>
<?php Util::registerScriptFile(Util::themeUrl().'/js/jquery.form.js');?>